package com.itheima.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

public class Demo02 {

    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>(List.of("张三丰", "张翠山", "张无忌", "王二麻子", "张良", "谢广坤", "赵四"));
        list.stream().filter(x->x.startsWith("张")).filter(x->x.length()==3).forEach(s-> System.out.println(s));
        System.out.println("+++++++++++++++");
        list.stream().limit(5).forEach(s-> System.out.println(s));
        System.out.println("+++++++++++++++");
        list.stream().skip(3).forEach(s-> System.out.println(s));
        System.out.println("+++++++++++++++");
        Stream<String> limit = list.stream().limit(5);
        Stream<String> skip = list.stream().skip(3);
        Stream.concat(limit,skip).forEach(s-> System.out.println(s));
        System.out.println("+++++++++++++++");
        Stream<String> limit1 = list.stream().limit(5);
        Stream<String> skip2 = list.stream().skip(3);
        Stream.concat(limit1,skip2).distinct().forEach(s-> System.out.println(s));
        System.out.println("+++++++++++++++");
        System.out.println(list.stream().count());
        System.out.println(list);
    }
}
